<template>

  <div class="product-add">
    <el-form size="small" ref="form" :model="form" label-width="150px">
      <div class="common-form">隐私协议</div>
      <el-form-item label="隐私协议：">
        <Uediter :text="form.content" :config="ueditor.config" ref="ue" @contentChange="contentChangeFunc"
          v-if="!loading">
        </Uediter>
      </el-form-item>
      <!--提交-->
      <div class="common-button-wrapper">
        <el-button type="primary" @click="onSubmit" :loading="loading">提交</el-button>
      </div>
    </el-form>
  </div>

</template>

<script>
import NewsApi from '@/api/news.js';
import Uediter from '@/components/UE.vue';
export default {
  components: {
    /*编辑器*/
    Uediter,
  },
  data() {
    return {
      ueditor: {
        text: '',
        config: {
          initialFrameWidth: 400,
          initialFrameHeight: 500
        }
      },
      /*form表单数据*/
      form: {
        id: 5,
        content: ''
      },
      loading: true,
    };
  },
  created() {
    this.getData()
  },

  methods: {
    /*获取富文本内容*/
    contentChangeFunc(e) {
      this.form.content = e;
    },
    getData() {
      let self = this;
      self.loading = true;
      NewsApi.get_about_us({ id: 5 }, true)
        .then(data => {
          self.form.content = data.data.content;
          self.loading = false;

        })
        .catch(error => { });

    },
    //提交表单
    onSubmit() {
      let self = this;
      self.loading = true;
      let params = this.form;
      NewsApi.set_about_us(params, true)
        .then(data => {
          self.loading = false;
          self.$message({
            message: '恭喜你，设置成功',
            type: 'success'
          });

        })
        .catch(error => {
          self.loading = false;
        });
    },
  }

};
</script>

<style>
.tips {
  color: #ccc;
}
</style>
